<template>
  <div>
    <ZgEdit
      ref="dialog"
      :columns="columns"
      :formulas="formulas"
      :inputClick="inputClick"
      validUrl=""
      saveUrl=""
      :view="view"
      :showFooter="showFooter"
      @ok="$emit('ok')">
    </ZgEdit>
  </div>
</template>
<script>
export default {
  data () {
    return {
      view: {
        width: '60%',
        top: '3%',
        title: '编辑'
      },
      columns: [
        // { name: '用户名', code: 'username', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        // { name: '联系电话', code: 'phone', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        // { name: '用户密码', code: 'password', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        // { name: '账号状态', code: 'status', compType: '单选', isNeed: false, offset: 0, span: 12, defaultVal: '1', extra: { 选项: [{ value: '1', label: '启用' }, { value: '2', label: '禁用' }] } },
        // { name: '关联角色', code: 'role', compType: '下拉选择', isNeed: true, offset: 0, span: 12, defaultVal: '', extra: { 下拉选项: [{ value: '1', label: '平台管理员' }, { value: '2', label: '系统管理员' }] } }

        { name: '所属企业', code: 'companyId', compType: '下拉选择', isNeed: true, offset: 0, span: 12, defaultVal: '', extra: { 下拉选项: [] } },
        { name: '关联角色', code: 'roleIds', compType: '下拉选择', isNeed: true, offset: 0, span: 12, defaultVal: '', extra: { 下拉选项: [{ value: '1', label: '平台管理员' }, { value: '2', label: '系统管理员' }] } },
        { name: '用户名', code: 'username', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        { name: '联系电话', code: 'phone', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        { name: '用户密码', code: 'password', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        { name: '确认密码', code: 'confirmPassword', compType: '单行文本', isNeed: true, offset: 0, span: 12, defaultVal: '' },
        { name: '账号状态', code: 'isOpen', compType: '开关', isNeed: true, offset: 0, span: 12, defaultVal: '1', extra: { 选项: [{ value: '1', label: '启用' }, { value: '2', label: '禁用' }] } }
      ],
      formulas: [],
      showFooter: false,

    }
  },
  methods: {
    open (json, pageType) {
      if (pageType === 'details') {
        this.$refs.dialog.open(json)
        this.view.title = '详情'
        this.showFooter = false
      } else {
        this.$refs.dialog.open(json)
        this.view.title = '编辑'
        this.showFooter = true
      }
    },
    inputClick (t) {
      alert(JSON.stringify(t))
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
